package main

import "fmt"

func main() {
	////定义切片：
	//slice := make([]int, 4, 20)
	//slice[0] = 66
	//slice[1] = 88
	//slice[2] = 99
	//slice[3] = 100
	////方式1：普通for循环
	//for i := 0; i < len(slice); i++ {
	//	fmt.Printf("slice[%v] = %v \t", i, slice[i])
	//}
	//fmt.Println("\n------------------------------")
	////方式2：for-range循环：
	//for i, v := range slice {
	//	fmt.Printf("下标：%v ，元素：%v\n", i, v)
	//}

	//var arr1 = [3]int{1, 2, 3}
	//for i := 0; i < len(arr1); i++ {
	//	fmt.Printf("%d ", arr1[i])
	//}
	//fmt.Println()
	//
	//var slice []int = arr1[0:2]
	//for i := 0; i < len(slice); i++ {
	//	fmt.Printf("%d ", slice[i])
	//}
	//fmt.Println()

	/**
	slice1 := make([]int, 4, 20)
	var slice2 []int = make([]int, 4, 20)

	slice1[0] = 1
	slice1[1] = 2
	slice1[2] = 3
	slice1[3] = 4

	slice2[0] = 1
	slice2[1] = 2
	slice2[2] = 3
	slice2[3] = 4

	for k, v := range slice1 {
		fmt.Printf("%d, %v | ", k, v)
	}
	fmt.Println()

	for k, v := range slice2 {
		fmt.Printf("%d, %v | ", k, v)
	}
	fmt.Println()
	*/

	var arr [10]int = [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	slice := arr[1:8]
	for i := 0; i < len(slice); i++ {
		fmt.Printf("%d ", slice[i])
	}
	fmt.Println()
}
